#include<iostream>
#include<unistd.h>
#include<signal.h>

//valatile的意思是不做优化：
volatile int gval = 1;
void changeData(int sig)
{
    std::cout << "change gval 1->0" << std::endl;
    //这是内存级的修改：
    gval = 0;  
}

int main()
{
    signal(2, changeData);
    while(gval);
    std::cout << "process[" << getpid() << "] exit!!!" << std::endl;
}